// ====== Computer Graphics Experiment #2 ======
// |     Midpoint Circle and Ellipse           |
// |           Drawing Algorithm               |
// =============================================
//
// Requirement:
// (1) Implement midpoint circle drawing algorithm.
// (2) Implement midpoint ellipse drawing algorithm.
// Use GL_POINTS mode for circle and ellipse
// Use GL_LINES to fill pixel spans 

#include <windows.h>
#include <GL/glut.h>
#include <math.h>

// Midpoint circle algorithm
void MyCircle(int xc, int yc, int r)
// (xc, yc) --- Center coordinates
// r --- Radius
{
	// Write your code here
}


// Midpoint ellipse algorithm
void MyEllipse(int xc, int yc, int rx, int ry)
// (xc, yc) --- Center coordinates
// rx --- Radius in x direction
// ry --- Radius in y direction
{
	// Write your code here
}



// width and height of program window
int width, height;

// Display callback function
void display(void)
{
	glClear (GL_COLOR_BUFFER_BIT);

	glColor3f(1.0, 0.0, 0.0);
	MyCircle(150, 150, 100);
	glColor3f(1.0, 0.0, 1.0);
	MyCircle(150, 150, 60);

	glColor3f(1.0, 1.0, 1.0);
	MyEllipse(150, 350, 131, 50);
	MyEllipse(400, 350, 29, 89);
	
	glFlush();
}

// Reshape callback function
void reshape(int w, int h)
{
	width=w;
	height=h;

	glViewport(0, 0, w, h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D (0.0, w, 0.0, h);
}

// Keyboard callback function
void keyboard(unsigned char key, int x, int y)
{
	switch (key) {
		case 27:
			exit(0);
	}
}

// Main program entrance
int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_RGB);
	glutInitWindowSize(600, 500);
	glutCreateWindow("Circles and Ellipses");
	glutReshapeFunc(reshape);
	glutKeyboardFunc(keyboard);
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}
